import React, { Component } from 'react'
import { Icon } from 'react-vant';
import axios from "../utils/request"
export default class Exit extends Component {

    state = {
        token: localStorage.getItem('token')
    }

    go = () => {
        this.props.history.push('/main/my')
    }

    tui = () => {
        this.props.history.push('/login')
        const name = localStorage.getItem('username')
        window.localStorage.clear()
        axios({
            url: '/api/shanchu',
            method: 'post',
            data: { value: name }
        }).then(res => {
            console.log(res);
        })
    }

    render() {
        return (
            <div className='wrap'>
                <header>
                    <div className="tou">
                        <Icon name="arrow-left" className='icons' onClick={() => { this.go() }} />
                        <span>设置</span>
                    </div>
                </header>
                <main>
                    <div className="ex">
                        <p>消息通知<Icon name="arrow" className='ico' /></p>
                        <p>清除存<Icon name="arrow" className='ico' /></p>
                        <button onClick={() => { this.tui() }}>注销账户</button>
                    </div>
                </main>
            </div>
        )
    }
}
